package ua.edu.sumdu.j2se.roman.lab1.model;


import ua.edu.sumdu.j2se.roman.lab1.domain.Task;
import ua.edu.sumdu.j2se.roman.lab1.domain.TaskList;
import ua.edu.sumdu.j2se.roman.lab1.exceptions.FileSerializationException;

import java.util.Date;
import java.util.Observable;
/**
 * Author: Radko Roman.
 */

/**
 * There is interface that describes some methods for working with the model.
 *
 */
public interface TasksModel {
    /**
     * Must gets task with time that nearest to now.
     *
     * @return  task
     */
    Date getFirstTaskDateFromNow();

    /**
     * Must gets task that are performed in specified time.
     *
     * @param key   date
     * @return  list of tasks
     */
    TaskList getTasksByDate(Date key);

    /**
     * Must add task to the list.
     *
     * @param task  to be added
     */
    void addTask(Task task);

    /**
     * Must gets list of task.
     *
     * @return  list of task
     */
    TaskList getTasks();

    /**
     * Must gets task from the list by title.
     *
     * @param title of the task
     * @return  task
     */
    Task getTaskByTitle(String title);

    /**
     * Must remove task from the list by title.
     *
     * @param task  task to be removed from the list
     */
    void deleteTask(Task task);

    /**
     * Must saves all data in file.
     *
     * @throws FileSerializationException   in case if can not save task
     */
    void saveData() throws FileSerializationException;

    /**
     * This method must return listeners any changes of the model.
     *
     * @return  changed model
     */
    Observable observable();

    void postponeTask(Task task, Date nextTime);
}
